home *** CD-ROM | disk | FTP | other *** search
/ Inter.Net 55-2 / Inter.Net 55-2.iso / Mandrake / mdkinst / usr / bin / perl-install / standalone / drakxservices < prev    next >
Encoding:
Text File  |  2000-01-12  |  1.0 KB  |  42 lines

  1. #!/usr/bin/perl
  2.  
  3. use lib qw(/usr/lib/libDrakX);
  4.  
  5. use common qw(:common :functional :file);
  6. use interactive;
  7. use log;
  8.  
  9. local $_ = join '', @ARGV;
  10.  
  11. /-h/ and die "usage: drakxservices\n";
  12.  
  13. $::isStandalone = 1;
  14.  
  15. my $in = vnew interactive('su');
  16.  
  17. my @l = grep { !/\.rpm/ } map { chop; $_ } `cd /etc/rc.d/init.d ; grep -l "chkconfig:" *`;
  18. my @before = map { bool(@_ = glob("/etc/rc.d/rc*.d/S*$_"))  } @l;
  19.  
  20. my $after = $in->ask_many_from_list("drakxservices",
  21. _("Choose which services should be automatically started at boot time"),
  22.     \@l, \@before);
  23.  
  24. mapn { 
  25.     my ($name, $before, $after) = @_;
  26.     if ($before != $after) {
  27.     if ($after) {
  28.         if (cat_("/etc/rc.d/init.d/$name") =~ /^chkconfig:\s+-/m) {
  29.         system("chkconfig --add $name");
  30.         } else {
  31.         `/sbin/runlevel` =~ /\s(\d+)/ or die "bad runlevel";
  32.         $1 == 3 || $1 == 5 or log::l("strange runlevel: ``$1'' (neither 3 nor 5)");
  33.         system("chkconfig --level $1 $name on");
  34.         }
  35.     } else {
  36.         system("chkconfig --del $name");
  37.     }
  38.     }
  39. } \@l, \@before, $after if $after;
  40.  
  41. $in->exit(0);
  42.